
<?php
/**
 * Created by PhpStorm.
 * User: 彭奇
 * Date: 2018/9/26
 * Time: 11:37
 */
//phpinfo();

try {
    $pdo = new PDO("mysql:dbname=test;host=127.0.0.1", "root", "");
    $pdo->exec("SET NAMES 'utf8';");
    $sql = "SELECT *FROM pq_com INNER JOIN pq_user ON pq_com.`user_id`=pq_user.`id`";
    $res = $pdo->query($sql);
    echo "<table border='1'>";
    foreach ($res as $row)
    {
        echo "<tr>";
        echo "<td>{$row['user_id']}</td>";
        echo "<td>{$row['name']}</td>";
        echo "<td>{$row['text']}</td>";
        echo "</tr>";
    }
    echo "</table>";
}catch (Exception $e)
{
    echo "连接失败".$e->getMessage();
}
